package com.itcc.controller;

import cn.dsna.util.images.ValidateCode;

import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//生成验证码
@WebServlet("/code")
public class Codecontroller extends BaseServlet{
    public void createCode(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //生成验证码对象
        //宽，高，干扰线数量和干扰点数量
        ValidateCode validateCode=new ValidateCode(100,35,5,20);

        //放入session
        String code=validateCode.getCode();
        request.getSession().setAttribute("code",code);

        //向页面写回验证码
        ServletOutputStream outputStream=response.getOutputStream();
        validateCode.write(outputStream);

    }



}
